﻿using B.S.DataBase.MyProject.Domain;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyRead.API.Appicant.Command.MenuCommand;
using B.S.DataBase.MyRead.API.Appicant.Command.RoleMenuCommand;
using B.S.DataBase.MyRead.API.DTOs;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.DataBase.MyRead.API.Controllers
{
    /// <summary>
    /// 角色菜单分配
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoleMenuController : ControllerBase
    {
        private readonly IMediator mediator;

        public RoleMenuController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 查询菜单名称
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<APIResult<List<MenuModel>>> GetMenuName([FromQuery] GetRoleMenuNameCommand request)
        {
            return await mediator.Send(request);
        }


        /// <summary>
        /// 反填获取菜单(名称,id)
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<APIResult<List<MenuDTOs>>> GetMenuNameFanTian([FromQuery] GetFanTianCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 通过用户id查询所对应的菜单
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<MenuDTOs>>> GetUserMenu([FromQuery]GetRoleMenuCommand request)
        {
            return await mediator.Send(request);
        }

    }
}
